import multiprocessing as mp
import threading as td
import time

def job(q):
    data = 0
    for i in range(1000000):
        data += 1
    q.put(data)

def start():
    q = mp.Queue()
    t1 = td.Thread(target=job,args=(q,))
    t2 = td.Thread(target=job,args=(q,))
    t1.start()
    t2.start()
    t1.join()
    t2.join()
    data1 = q.get()
    data2 = q.get()
    print(data1+data2)

def multi():
    q = mp.Queue()
    m1 = mp.Process(target=job, args=(q,))
    m2 = mp.Process(target=job, args=(q,))
    m1.start()
    m2.start()
    m1.join()
    m2.join()
    data1 = q.get()
    data2 = q.get()
    print(data1 + data2)

def job_2():
    data = 0
    for i in range(2):
        for i in range(1000000):
            data += 1
    print(data)

if __name__ == '__main__':
    time1 = time.time()
    job_2()
    time_4 = time.time()
    print('没有程时间：',time_4-time1)
    start()
    time2 = time.time()
    print('线程时间：',time2-time1)
    multi()
    time3 = time.time()
    print("进程时间：",time3-time1)